@extends('home/layout')
@section('content')
<style type="text/css">
	.pmar
    {
        height:20px;
        color:#DC0505;
    }
</style>
<link href="/home/css/personal.css" rel="stylesheet" type="text/css"/>
<div style="background-color: #1C546B; margin-top:none;">
	<div class="container" style="width:900px;"> <!--MC导航-->
		<h2 id="c-title">个人设置 ·<small> 基本资料</small></h2>
		<div>
			<div id="c-body">
				<div class="row" style="height:650px;">
					<div class="col-md-2" id="c-dhl">
						<ul class="list-unstyled">
							<li class="text-center"><a href="{{ url('/home/user/personal') }}">&nbsp;基本资料<a></li>
							<hr>
							<li class="text-center"><a href="{{ url('/home/user/photo') }}">修改头像</a></li>
							<hr>
							<li class="text-right"><strong>修改密码 &nbsp;</strong><span class="fa fa-hand-o-right"></span></li>
						</ul>
					</div>
					<div class="col-md-10">
						<div style="height:50px;"></div>
						<div style="width:500px; margin:0 auto;">
							<form action="{{ url('/home/user/newpwd') }}" method="post" role="form">
			                {{ csrf_field() }}
			                <input type="hidden" name="id" value="{{ session('user') -> id }}">
			                    <p class="pmar"></p>
			                    <div>
			                        <input type="password" name="oldpassword" class="form-control" placeholder="旧密码" id="regEmail">
			                    </div>
			                    <p class="pmar" id="pmar1"></p>
			                    <div>
			                        <input type="password" name="password" class="form-control" placeholder="新密码(6—20位数字与字母、下划线组合)" id="regPwd">
			                    </div>
			                    <p class="pmar" id="pmar2"></p>
			                    <div>
			                        <input type="password" class="form-control" placeholder="确认新密码" id="regTpwd">
			                    </div>
			                    <p class="pmar" id="pmar3"></p>
			                    <div>
                        			<button type="submit" class="btn btn-primary btn-lg btn-block" name="reg" disabled="disabled">确认修改</button>
                    			</div>
						    <form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	var info = "{{ session('info') }}";
	if(info != '')
	{
		alert(info);
	}
	//正则匹配密码输入框
    $('input[id="regPwd"]').on('blur', function(){
        //获取输入的值
        var v = this.value;
        // console.log(v);
        //声明正则
        var reg = /^[a-z0-9_-]{6,20}$/;
        //验证
        var res = reg.test(v);
        //判断
        if(res)
        {
            $('#pmar2').html('');
            this.style.border = '1px solid #0f0';
        }else {
            this.style.border = '1px solid #f00';
            $('#pmar2').html('密码由6-20位数字，字母，下划线组合');
        }
    })
    //正则匹配重复密码
    $('input[id="regTpwd"]').on('keyup', function(){
        //获取输入的值
        var v = this.value;
        var p = $('input[id="regPwd"]').attr('value');
        //判断
        if(v == p)
        {
            $('#pmar3').html('');
            this.style.border = '1px solid #0f0';
            $('button[name="reg"]').attr('disabled',false);
        }else {
            this.style.border = '1px solid #f00';
            $('#pmar3').html('两次密码不一致');
            $('button[name="reg"]').attr('disabled','disabled');
        }
    })
	
</script>
@endsection